package com.atguigu.mybatisplus.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import lombok.Data;

import java.time.LocalDateTime;

/**
 * Description:
 *
 * @ author: ChiPu
 * date: 2021/11/13 19:48
 */
@Data
//@TableName(value = "t_user").....实体类的名字是User，数据库表名是t_user
public class User{

    //@TableId(value = "uid")
    // private String id;

    // @TableId(type = IdType.ASSIGN_ID)  IdType.ASSIGN_ID：使用基于雪花算法的策略生成数据id
    // private Long id;

    // @TableId(type = IdType.AUTO)     IdType.AUTO：使用数据库的自增策略

    //#全局设置主键生成策略
    // #mybatis-plus.global-config.db-config.id-type=auto


    private Long id;
    private String name;
    private Integer age;
    private String email;

    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createTime;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;

    @TableLogic
    @TableField(value = "is_deleted")
    private Integer deleted;

    //测试删除：删除功能被转变为更新功能
    // -- 实际执行的SQL
    // update user set is_deleted=1 where id = 1 and is_deleted=0
    // 测试查询：被逻辑删除的数据默认不会被查询
    // -- 实际执行的SQL
    // select id,name,is_deleted from user where is_deleted=0
}